﻿using System;
using Skynet.CommonLibrary.ThreadRefreshTime.Interface;

namespace Skynet.CommonLibrary.ThreadRefreshTime.RefreshElement
{
    /// <summary>
    /// 简单时间元素 用于立刻执行刷新任务
    /// </summary>
    ///<remarks>
    /// 作者：         李志强
    /// 开发时间：  2011-03-28
    /// </remarks>
    public class TimerElement:IRefreshTimer
    {
        public TimerElement(int interval)
        {
            RefreshInterval = interval;
        }
        #region IRefreshTimer 成员

        public int RefreshInterval
        {
            get;
            set;
        }

        public Action<Action<IRefreshTimer, Exception>> Refresh
        { get; set; }

        public string RefreshID
        {
            get;
            set;
        }

        public DateTime LastRefreshTime
        {
            get;
            set;
        }

        public DateTime ExecutionTime
        {
            get;
            set;
        }

        public string Description
        {
            get;
            set;
        }

        public void Verify()
        {
            if (string.IsNullOrEmpty(this.RefreshID))
            {
                this.RefreshID = Guid.NewGuid().ToString();
            }
        }
        #endregion

    }
}
